package com.wsd.serviceImpl;

import com.cif.common.Result;
import com.cif.service.AccountService;
import com.cif.service.ContacterService;
import com.cif.service.CustomerService;
import com.cif.service.domain.AccountInfoDTO;
import com.cif.service.domain.ContacterDTO;
import com.cif.service.domain.CustomerDTO;
import com.wsd.service.ICifService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class CifServiceImpl implements ICifService {

    @Reference(version = "1.0.0", url = "${dubbo.service.cifurl}")
    private CustomerService customerService;

    @Reference(version = "1.0.0", url = "${dubbo.service.cifurl}")
    private ContacterService contacterService;

    @Reference(version = "1.0.0", url = "${dubbo.service.cifurl}")
    private AccountService accountService;

    /**
     * 获取所有用户信息（用户信息列表）
     *
     * @param pageNo   第几页
     * @param pageSize 一共多少页
     * @return
     */
    @Override
    public Result getCustomerInfoList(int pageNo, int pageSize) {
        return customerService.getCustomerInfoList(pageNo,pageSize);
    }

    /**
     * 根据用户状态获取用户信息（三种状态：正常、短期逾期、长期逾期）
     *
     * @param status
     * @param pageSize
     * @param pageNo
     * @return
     */
    @Override
    public Result getCustomerInfoListByStatus(String status, int pageSize, int pageNo) {
        return customerService.getCustomerInfoListByStatus(status,pageSize,pageNo);
    }

    /**
     * 根据用户id获取用户信息
     *
     * @param userId
     * @return
     */
    @Override
    public Result getCustomerById(String userId) {
        return customerService.getCustomerById(userId);
    }

    /**
     * 用户注册
     *
     * @param customer
     * @param contacter
     * @return 用户id
     */
    @Override
    public Result register(CustomerDTO customer, ContacterDTO contacter) {
        return customerService.register(customer,contacter);
    }

    /**
     * 更新用户信息
     *
     * @param customer
     * @return
     */
    @Override
    public Result updateCustomer(CustomerDTO customer) {
        return customerService.updateCustomer(customer);
    }

    /**
     * 批量插入联系人
     *
     * @param contacterList
     * @return
     */
    @Override
    public int insertContacterBatch(List<ContacterDTO> contacterList) {
        return contacterService.insertContacterBatch(contacterList);
    }

    /**
     * 更新联系人
     *
     * @param contacter
     * @return
     */
    @Override
    public Result updateContacter(ContacterDTO contacter) {
        return contacterService.updateContacter(contacter);
    }

    /**
     * 根据卡号查询账户信息
     *
     * @param cardNumber
     * @return
     */
    @Override
    public Result getAccountInfo(String cardNumber) {
        return accountService.getAccountInfo(cardNumber);
    }

    /**
     * 放款
     *
     * @param userId
     * @param loanNumber
     * @return
     */
    @Override
    public Result loanToAccount(Long userId, BigDecimal loanNumber) {
        return accountService.loanToAccount(userId,loanNumber);
    }

    /**
     * 批量放款
     *
     * @param list
     * @return
     */
    @Override
    public Result loanBatch(List<AccountInfoDTO> list) {
        return accountService.loanBatch(list);
    }
}
